#include "tools.h"
QByteArray getTrainMessage(const QString &username,const QString &setting)
{
    CryptString crypt(username+setting);//构建MD5

    QString encryp=setting +"$"+  crypt.generateMD5();//组成加密密文

    int usernamesize=username.size();
    int encryptsize=encryp.size();
    int msglength=4+usernamesize+4+44;
    char * msg = new char[msglength];

    //组装用户名和加密密文
    memcpy(msg, (char*)&usernamesize, 4);
    memcpy(msg+4, username.toUtf8().data(), usernamesize);
    memcpy(msg+4+usernamesize, (char*)&encryptsize, 4);
    memcpy(msg+4+usernamesize+4, encryp.toUtf8().data(),encryptsize);

    return QByteArray(msg,msglength);
}
